<?php

class Mod_Activity extends CI_Model{
		
	public function getActivity($start, $num, $type){
		$this->db->select('*');
		$this->db->where(field('type'), $type);
        $this->db->limit($num, $start);
		$this->db->order_by(field('id'), 'DESC');
		return $this->db->get(table('activity'));
	}
	
    public function getActivityNum($type){
        $objDb = $this->getAllActivity($type);
        return $objDb->num_rows();
    }
	
    public function getAllActivity($type) {
        $this->db->select('*');
        $this->db->from(table('activity'));
		$this->db->where(field('type'), $type);
		return $this->db->get();
    }
	
    public function getActivityById($id) {
        $this->db->select('*');
        $this->db->where(field('id'),$id);
		$result = $this->db->get(table('activity'));
		$result = $result->result_array();
		return $result[0];
    }
	
	public function getLastestNews($limit){
        $this->db->select('*');
        $this->db->from(table('activity'));
		$this->db->order_by(field('id'), 'DESC');
        $this->db->limit($limit);
		return $this->db->get();
	}
}